package net;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpTranslateServer extends UdpEchoServer{
    private Map<String,String> map = new HashMap<>();

    public UdpTranslateServer(int port) throws SocketException {
        super(port);
        map.put("cat","小猫");
        map.put("dog","小狗");
        map.put("yellow","黄色");
        map.put("bule","lanse");
        map.put("wocao","卧槽");
        //............
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"词在词典中未找到");
    }

    public static void main(String[] args) throws IOException {
        UdpTranslateServer serve = new UdpTranslateServer(9090);
        serve.Start();
    }
}
